home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / toolkit / vbof_v11 / democomp.cls < prev    next >
Text File  |  1996-03-01  |  3KB  |  137 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "Company"
  6. Attribute VB_Creatable = False
  7. Attribute VB_Exposed = True
  8. Option Explicit
  9.  
  10. ' the following pertain to being supported by
  11. '   VBOFCollection, VBOFObjectManager and
  12. '   VBOFEventManager
  13. 'Public ObjectID As Long
  14. Public ObjectChanged As Long
  15. Public ObjectAdded As Long
  16. Public ObjectDeleted As Long
  17. Public ObjectParentCount As Long
  18. Public ObjectManager As VBOFObjectManager
  19.  
  20. ' the following code pertains to the business
  21. '   of the Company object
  22. Private pvtPersonsCollection As VBOFCollection
  23.  
  24.  
  25. Private Sub Class_Terminate()
  26.     If Not ObjectManager Is Nothing Then
  27.         ObjectManager.TerminateObject _
  28.             Object:=Me
  29.     End If
  30. End Sub
  31.  
  32.  
  33. Public Function ObjectHasChanged()
  34. ' Mark this object as "Changed" and trigger the
  35. '   "Changed" event
  36.  
  37.     ObjectChanged = True
  38.     
  39. #If NoEventMgr = False Then
  40.     If Not ObjectManager Is Nothing Then
  41.         ObjectManager. _
  42.             TriggerObjectEvent _
  43.                 Event:="Changed", _
  44.                 Object:=Me
  45.     End If
  46. #End If
  47. End Function
  48.  
  49.  
  50. Public Function ObjectEventCallBack(Optional Event As Variant, Optional Object As Variant) As Long
  51. ' Receive the Trigger notification and process
  52. '   accordingly
  53. '
  54. ' Parameters:
  55. '   Event
  56. '       a string which identifies the Event
  57. '       Example: "Changed", "Created", "Deleted"
  58. '   Object
  59. '       the object originating the Event.
  60. '       responds to:
  61. '           TypeName(TriggerObject)
  62. '           TriggerObject.ObjectID
  63. ' (supported by VBOFEventManager)
  64.  
  65. End Function
  66.  
  67.  
  68.  
  69.  
  70. Public Function ObjectDataSource() As String
  71.     ObjectDataSource = "Company"
  72. End Function
  73.  
  74. Public Function EmptyPersons() As Variant
  75. ' Return an emptied Persons collection
  76. '   (handy when wanting to begin processing the Company
  77. '   after having already done some things with it)
  78.  
  79.     Set pvtPersonsCollection = _
  80.         ObjectManager. _
  81.             NewVBOFCollection _
  82.                 (Parent:=Me)
  83.  
  84.     ObjectHasChanged
  85.     Set EmptyPersons = Persons()
  86. End Function
  87.  
  88.  
  89. Public Function Persons(Optional ObjectID As Variant) As Variant
  90. ' Returns a VBOFCollection of Person objects which are
  91. '   contained by this Company object,
  92. ' or
  93. ' Returns a Person object whose ObjectID matches the ObjectID
  94. '   parameter.
  95.  
  96.     Dim tempNewPerson As New Person
  97.  
  98.     Set Persons = _
  99.         ObjectManager. _
  100.             ManageCollection( _
  101.                 ObjectID:=ObjectID, _
  102.                 Collection:=pvtPersonsCollection, _
  103.                 Parent:=Me, _
  104.                 Sample:=tempNewPerson, _
  105.                 Database:=CompanyDatabase, _
  106.                 OrderByClause:="LastName ASC, FirstName ASC")
  107. ' other available parameters:
  108. '               ODBCPassThrough:=True,
  109. '               ANSISQL:=True,
  110.  
  111. End Function
  112. Public Function AddPerson(Optional Item As Variant, Optional Parent As Variant) As Person
  113. ' Return a Person, added to my pvtPersonsCollection
  114. '   (just a wrapper method for Persons.Add)
  115.  
  116.     Set AddPerson = Me.Persons.Add( _
  117.         Item:=Item, _
  118.         Parent:=Me, After:=Me.Persons(1))
  119.     
  120.     ObjectHasChanged
  121. End Function
  122.  
  123.  
  124.  
  125. Private Sub Class_Initialize()
  126.    Set ObjectManager = Nothing
  127. End Sub
  128.  
  129.  
  130.  
  131. Public Property Get ObjectID() As Long
  132.     ObjectID = 1
  133. End Property
  134.  
  135.  
  136.  
  137.